/*
 * @Author: reiner850593913 lk850593913@gmail.com
 * @Date: 2022-08-27 23:43:29
 * @LastEditors: ReinerLau lk850593913@gmail.com
 * @LastEditTime: 2022-12-26 14:20:32
 * @FilePath: \robot-management-web\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import svgLoader from "vite-svg-loader";
import eslint from "vite-plugin-eslint";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import vueJsx from "@vitejs/plugin-vue-jsx";

const eslintOptions = {
  fix: true,
  cache: false,
  failOnWarning: true,
};
const svgPluginOptions = {
  // 指定需要缓存的图标文件夹
  iconDirs: [path.resolve(process.cwd(), "src/icons")],
  // 指定symbolId格式
  symbolId: "icon-[dir]-[name]",
};

export default defineConfig({
  plugins: [
    vue(),
    svgLoader(),
    eslint(eslintOptions),
    createSvgIconsPlugin(svgPluginOptions),
    vueJsx(),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server: {
    proxy: {
      "/api": {
        target: "http://119.91.145.64:8081",
        changeOrigin: true,
      },
      "/websocket": {
        target: "ws://localhost:3000",
        ws: true,
      },
    },
  },
  build: {
    sourcemap: true,
  },
});
